#pragma once

#include "Types.h"
#include <cassert>

enum EDaysOfTheWeek
{
	SUNDAY = 0,
	MONDAY,
	TUESDAY,
	WEDNESDAY,
	THURSDAY,
	FRIDAY,
	SATURDAY,
	NUM_DAYS_OF_THE_WEEK
};

extern const char* const DaysOfTheWeekNames[NUM_DAYS_OF_THE_WEEK];

enum EMonths
{
	JANUARY = 0,
	FEBRUARY,
	MARCH,
	APRIL,
	MAY,
	JUNE,
	JULY,
	AUGUST,
	SEPTEMBER,
	OCTOBER,
	NOVEMBER,
	DECEMBER,
	NUM_MONTHS
};

extern const char* const MonthNames[NUM_MONTHS];

inline uint GetDayOfTheWeek(const uint i_day, const uint i_firstSunday)
{
	return i_day + 7 - i_firstSunday;
}

inline bool IsLeapYear(const uint i_year)
{
	return (i_year%4==0) && ((i_year%100!=0) || (i_year%400==0));
}

inline uint GetMonthOfDay(const uint i_day, const uint i_year)
{
	static uint numDayOfMonths[] = {31,28,31,30,31,30,31,31,30,31,30,31};
	numDayOfMonths[1] = IsLeapYear(i_year) ? 29u : 28u;

	uint day = i_day;
	for(uint i = 0; i<NUM_MONTHS; ++i)
	{
		if(day <= numDayOfMonths[i])
			return i;

		day -= numDayOfMonths[i];
	}

	//error
	assert(0);
	return static_cast<uint>(-1);
}
